package com.ikaros.model.entity;

import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.enums.IdType;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.ikaros.emnus.LoginEnum;
import com.ikaros.emnus.SexEnum;
import com.ikaros.emnus.StatusEnum;
import com.ikaros.utils.EnumUtil;
import lombok.Data;
import org.apache.commons.lang3.EnumUtils;

import javax.persistence.*;
@Data
@Table(name = "sys_user")
public class SysUser {
    @Id
    @Column(name = "user_id")
    @TableId(type = IdType.AUTO)
    private Long userId;

    /**
     * 用户名
     */
    private String username;

    /**
     * 密码
     */
    @JsonIgnore
    private String password;

    /**
     * 性别 0=保密/1=男/2=女
     */
    private Integer sex;

    /**
     * 邮箱
     */
    private String email;

    /**
     * 手机号
     */
    private String mobile;

    /**
     * 最后登录时间
     */
    @Column(name = "last_login_time")
    private Integer lastLoginTime;

    /**
     * 最后登录IP
     */
    @Column(name = "last_login_ip")
    private String lastLoginIp;

    /**
     * 头像缩略图地址
     */
    @Column(name = "avatar_url")
    private String avatarUrl;

    /**
     * 状态  0：禁用   1：正常
     */
    private Integer status;

    /**
     * 创建时间
     */
    @Column(name = "create_time")
    private Integer createTime;

    @Transient
    public SexEnum getSexEnum(){
        return EnumUtil.getByCode(sex,SexEnum.class);
    }

    public StatusEnum getStatusEnum(){
        return StatusEnum.getStatusEnum(status);
    }

}